﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMSSyncData.Model;
using WMSSyncData.Model.WMSModel;
using WMSSyncData.Utils;

namespace WMSSyncData.DAL.Oracle
{
    public class Tddev121DAL : BaseOracleDAL<WMS_T_OutStock>
    {
        public List<WMS_T_OutStock> GetAll()
        {
            var sql = @"SELECT rawtohex(sys_guid()) guid,'B0101'||to_char(sysdate, 'yyMMdd')||LPAD (SEQ_WMS_M_outStock.NEXTVAL,5,'0') AS BillNo,temp.* FROM (  SELECT  '销售计划'
as  BillType,t$worn AS RelatedBill,'0' AS status ,t$stad CustomerContact,'admin' AS creator,SYSDATE as createTime,t$cwar as Storage_SN,t$wseq as SN,t$wpon as RowNo,t$wset as SetNo,t$revi as Ext3,t$Snama as CustomerName,t$stco as CustomerSN,t$nama as CustomerAddress  FROM TTDDEV121101 WHERE t$host=1) temp ";

            var dt = OracleDBHelper.GetDataSet(sql).Tables[0];

            var result = MakeTablePackage(dt);
            return result;
        }
   

        public List<WMS_T_OutStock> GetSPFData()
        {
            var sql = @"SELECT rawtohex(sys_guid()) as GUID,temp.* FROM(
SELECT DISTINCT BillNO,RelatedbillNo as RelatedBill,RowNo,CustomerSN,ToAddress as CustomerAddress, billtype,1 AS status,creator as Creator,createtime as createtime,nvl(OutWarehouse,' ') as Storage_SN,EXT1,EXT2,EXT3 FROM WMS_M_OUTSTOCK WHERE Data_Status=1 and billtype='半成品出库')temp";

            var dt = OracleDBHelper.GetDataSet(sql).Tables[0];

            var result = MakeTablePackage(dt);
            return result;
        }
    }
}
